﻿@model TrialManagmentTool.Models.TrialDetailViewModel
@using TrialManagmentTool.Models
@{
    ViewBag.Title = "试验点报告详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="@TrialManagementTool.Helper.UrlHelper.alterContent("Content/zzsc.css")" rel="stylesheet" />
<script src="@TrialManagementTool.Helper.UrlHelper.alterContent("Scripts/js/zooming.js")"></script>
<script>
    function DynamicDisplay(value, displayname, target) {
        if (value != "") {
            if (value == "True") { value = "是" }
            if (value == "False") { value = "否" }
            $("#" + target).append("<tr><td style=\"width:20%\" class=\"lighttrialword\">" + displayname + "</td><td class=\"tdalignright\">" + value + "</td></tr>");
        }
    }

    function DynamicDisplayForBasic(value, displayname, target) {
        if (value == "True") { value = "是" }
        if (value == "False") { value = "否" }
        $("#" + target).append("<tr><td style=\"width:20%\" class=\"lighttrialword\">" + displayname + "</td><td class=\"tdalignright\">" + value + "</td></tr>");
    }

    function DynamicDisplayFromLeft(value, displayname, target) {
        if (value != "") {
            if (value == "True") { value = "是" }
            if (value == "False") { value = "否" }
            $("#" + target).append("<tr><td style=\"width:10%\" class=\"lighttrialword\">" + displayname + "</td><td class=\"tddisplay\">" + value + "</td></tr>");
        }
    }

    function DynamicDisplayWithTextBoxFromLeft(value, displayname, target, id) {
        if (value != "") {
            $("#" + target).append("<tr><td style=\"width:10%\" class=\"lighttrialword\">" + displayname + "</td><td class=\"tddisplay\"><textarea id=\"" + id + "\" class=\"tabletextarea\" style='width:100%'> </textarea></td></tr>");
            $("#" + id).text(FormatTextAreaValue(value));
            init(id);
        }
    }

    function DynamicFinalReportDisplayFromLeft(value, displayname, target, id) {
        if (value != "") {
            if (value == "True") { value = "是" }
            if (value == "False") { value = "否" }
            $("#" + target).append("<tr><td style=\"width:20%\" class=\"lighttrialword\"> " + displayname + "</td><td style='font-size:12px'>" + value + "</td></tr>");
        }
    }
    function DynamicFinalReportDisplayFromLeftWithTextBox(value, displayname, target, id) {
        if (value != "") {
            $("#" + target).append("<tr><td style=\"width:20%\" class=\"lighttrialword\">" + displayname + "</td><td class=\"tddisplay\"><textarea id=\"" + id + "\" class=\"tabletextarea\" style='width:80%'> </textarea></td></tr>");
            $("#" + id).text(FormatTextAreaValue(value));
            init(id);
        }
    }
    var datasource;
    $.ajax({
        url: fixUrl("api/Trial/GetAllFieldsDataSource"),
        success: function (data) {
            datasource = data;
        }
    })

    function FormatReportValue(value, Field, type, target) {
        var content = "";
        if (type == "5") {
            if (value == "true") {
                content = "是";
            } else {
                content = "否";
            }
            $("#" + target).html(content);
        } else if (type == "4") {
            if (datasource == undefined) {
                setTimeout(function () { FormatReportValue(value, Field, type, target) }, 50);
            } else {
                $.each(datasource[Field], function (index, value2) {
                    if (value2.Value == value) {
                        $("#" + target).html(value2.Description);
                    }
                })
            }
        }
    }

</script>

<div class="mainCont">
    <div class="" style="position:fixed;margin-top:-30px;cursor:pointer">
        <a onclick="location.href=fixUrl('Home/Index')">
            <img src="@TrialManagementTool.Helper.UrlHelper.alterContent("Images/return.png")" />
            <span style="color:#00985f">返回</span>
        </a>
    </div>
    <div style="padding-top:10px">
        <div class="report-title" style="padding:10px;background-color:#00985f;color:#ffffff">基本信息</div>
        <div style="background-color:#ffffff">
            <div class="row">
                <div class="col-xs-5 baseinfo">
                    <label class="lighttrialword">TTM</label>
                    <select class="mar-l5 AdminInfo" id="ttmItem" style="font-size:14px"></select>
                    <label class="mar-l5 lighttrialword">项目类别</label>
                    <select class="mar-l5 AdminInfo" id="projectCategory" style="font-size:12px"></select>
                </div>
                <div class="col-xs-7 baseinfo">
                    <label class="lighttrialword">CA</label>
                    <input type="text" class="mar-l10 shawdow AdminInfo" id="caItem" value='@Model.trial.CA' />
                    <label class="mar-l10 lighttrialword">FSM</label>
                    <input type="text" class="mar-l10 shawdow AdminInfo" id="fsmItem" value='@Model.trial.FSM ' />
                    @if (Model.isShowEditButton == true)
                    {
                        <button type="button" class="btn btn-default" id="btnSave" style="display:none">保存</button>
                        <button type="button" class="btn btn-default" id="btnEdit">编辑</button>
                    }
                </div>
            </div>

            <div class="row">
                <div class="col-xs-5 baseinfo">
                    <table class="table" id="TrialInfoLeftTable"></table>
                </div>
                <div class="col-xs-5 baseinfo">
                    <table class="table" id="TrialInfoRightTable"></table>
                </div>
            </div>

            <div class="report-title" style="padding:10px;background-color:#00985f;color:#ffffff">示例方案</div>
            <div class="row">
                <table class="table" style="width:80%" id="PurposeTable"></table>
            </div>

            <div class="report-title" style="padding:10px;background-color:#00985f;color:#ffffff">示范点信息</div>
            <div class="row">
                <div class="col-xs-5 baseinfo">
                    <table class="table" id="BasicTable"></table>
                </div>
                <div class="col-xs-5 baseinfo">
                    <table class="table" id="BasicRightTable"></table>
                </div>
            </div>

            <div class="report">
                @for (int i = 0; i < Model.ProcessViewModelDataList.Count(); i++)
                {
                    <div class="report-title" style="padding:10px;background-color:#00985f;color:#ffffff">@Model.ProcessViewModelDataList[i].reportName</div>
                    <table class="table">
                        <tr>
                            <td>
                                <h4>用药信息</h4>
                            </td>
                        </tr>
                        @for (int k = 0; k < Model.ProcessViewModelDataList[i].NonObserveDataList.Count(); k++)
                        {
                            <tr>
                                <td>
                                    <h5 class="boldfont">@Model.ProcessViewModelDataList[i].NonObserveDataList[k].headTitle</h5>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="row">
                                        <div class="col-xs-5 ">
                                            <table class="table">
                                                @for (int j = 0; j < Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields.Count() / 2; j++)
                                                {
                                                    <tr>
                                                        <td class="lighttrialword" style="width:40%">
                                                            @Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].Name
                                                            @if (Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].IsMandary == true)
                                                            {<span class="markstar">&nbsp;*</span> }
                                                        </td>
                                                        <td class="tdalignright" id=@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].ID)>
                                                            @if (Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].DataType == 4 || Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].DataType == 5)
                                                            {
                                                                <script>FormatReportValue('@Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].Value', '@Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].FieldID', '@Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].DataType', '@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].ID)')</script>
                                                            }
                                                            else
                                                            {
                                                                @Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].Value
                                                            }
                                                        </td>
                                                    </tr>
                                                }
                                            </table>
                                        </div>

                                        <div class="col-xs-5 ">
                                            <table class="table" style="table-layout:fixed">
                                                @for (int j = Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields.Count() / 2; j < Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields.Count(); j++)
                                                {
                                                    <tr>
                                                        <td class="lighttrialword" style="width:40%">
                                                            @Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].Name
                                                            @if (Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].IsMandary == true)
                                                            {<span class="markstar">&nbsp;*</span> }
                                                        </td>
                                                        <td class="tdalignright" id=@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].ID)>
                                                            @if (Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].DataType == 4 || Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].DataType == 5)
                                                            {
                                                                <script>FormatReportValue('@Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].Value', '@Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].FieldID', '@Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].DataType', '@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].ID)')</script>
                                                            }
                                                            else
                                                            {
                                                                @Model.ProcessViewModelDataList[i].NonObserveDataList[k].inputFields[j].Value
                                                            }
                                                        </td>
                                                    </tr>
                                                }
                                            </table>
                                        </div>
                                    </div>
                                    @*<div style="background-color:#ffffff">
                                            <div class="report-image">
                                                @for (int j = 0; j < Model.trial.Reports[i].Images.Count(); j++)
                                                {
                                                    <img src=@( System.Text.Encoding.UTF8.GetString((Model.trial.Reports[i].Images[j].Image))) style="height:200px;width:200px;margin:10px" class="img-rounded" data-action="zoom" />
                                                }
                                            </div>
                                            <div class="report-content" style="padding:0 10px 10px 0px">
                                                <div class="lighttrialword">备注</div>
                                                <textarea class="tabletextarea" style='width:80%' id=@("comment_"+Model.trial.Reports[i].ID)> </textarea>
                                                <script>
                                                    $("#comment_"+@Model.trial.Reports[i].ID).text(FormatTextAreaValue('@Model.trial.Reports[i].Comments'));
                                                    init("comment_"+@Model.trial.Reports[i].ID);
                                                </script>
                                            </div>
                                        </div>*@

                                </td>
                            </tr>
                        }

                        <tr>
                            <td>
                                <h4>调查信息</h4>
                            </td>
                        </tr>
                        @for (int k = 0; k < Model.ProcessViewModelDataList[i].ObserveDataList.Count(); k++)
                        {
                            <tr>
                                <td>
                                    <h5 class="boldfont">@Model.ProcessViewModelDataList[i].ObserveDataList[k].headTitle</h5>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="row">
                                        <div class="col-xs-5 ">
                                            <table class="table">
                                                @for (int j = 0; j < Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields.Count() / 2; j++)
                                                {
                                                    <tr>
                                                        <td class="lighttrialword" style="width:40%">
                                                            @Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].Name
                                                            @if (Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].IsMandary == true)
                                                            {<span class="markstar">&nbsp;*</span> }
                                                        </td>
                                                        <td class="tdalignright" id=@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].ID)>
                                                            @if (Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].DataType == 4 || Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].DataType == 5)
                                                            {
                                                                <script>FormatReportValue('@Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].Value', '@Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].FieldID', '@Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].DataType', '@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].ID)')</script>
                                                            }
                                                            else
                                                            {
                                                                @Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].Value
                                                            }
                                                        </td>
                                                    </tr>
                                                }
                                            </table>
                                        </div>

                                        <div class="col-xs-5 ">
                                            <table class="table" style="table-layout:fixed">
                                                @for (int j = Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields.Count() / 2; j < Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields.Count(); j++)
                                                {
                                                    <tr>
                                                        <td class="lighttrialword" style="width:40%">
                                                            @Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].Name
                                                            @if (Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].IsMandary == true)
                                                            {<span class="markstar">&nbsp;*</span> }
                                                        </td>
                                                        <td class="tdalignright" id=@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].ID)>
                                                            @if (Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].DataType == 4 || Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].DataType == 5)
                                                            {
                                                                <script>FormatReportValue('@Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].Value', '@Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].FieldID', '@Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].DataType', '@("report_" + i + "item_" + Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].ID)')</script>
                                                            }
                                                            else
                                                            {
                                                                @Model.ProcessViewModelDataList[i].ObserveDataList[k].inputFields[j].Value
                                                            }
                                                        </td>
                                                    </tr>
                                                }
                                            </table>
                                        </div>
                                    </div>
                                    <div style="background-color:#ffffff">
                                        <div class="report-image">
                                            @for (int j = 0; j < Model.ProcessViewModelDataList[i].ObserveDataList[k].Images.Count(); j++)
                                            {
                                                <img src=@( System.Text.Encoding.UTF8.GetString((Model.ProcessViewModelDataList[i].ObserveDataList[k].Images[j].Image))) style="height:200px;width:200px;margin:10px" class="img-rounded" data-action="zoom" />
                                            }
                                        </div>
                                        @*<div class="report-content" style="padding:0 10px 10px 0px">
                                                <div class="lighttrialword">备注</div>
                                                <textarea class="tabletextarea" style='width:80%' id=@("comment_"+Model.trial.Reports[i].ID)> </textarea>
                                                <script>
                                                    $("#comment_"+@Model.trial.Reports[i].ID).text(FormatTextAreaValue('@Model.trial.Reports[i].Comments'));
                                                    init("comment_"+@Model.trial.Reports[i].ID);
                                                </script>
                                            </div>*@
                                    </div>
                                </td>
                            </tr>
                        }
                    </table>
                }
            </div>
            <div class="report-title" style="padding:10px;background-color:#00985f;color:#ffffff">总结</div>
            <div class="row">
                <table class="table" style="width:80%" id="FinalTable"></table>
            </div>
        </div>
    </div>


    @if (Model.trial.Status == 0 || Model.trial.Status == 1)
    {
        <div style="text-align:center;margin:20px;margin-bottom:200px" id="divReminder">
            <button type="button" class="btn btn-default" onclick=Reminder(@Model.trial.TrialSite.ID)>提醒</button>
            <button type="button" class="btn btn-default" onclick=DelConfirm(@Model.trial.TrialSite.ID)>删除</button>
        </div>
    }
    else if (Model.trial.Status == 2)
    {
        <div style="text-align:center;margin:20px;margin-bottom:200px" id="divOperate">
            <button type="button" class="btn btn-default" onclick=Approve(@Model.trial.TrialSite.ID)>批准</button>
            <button type="button" class="btn btn-default" onclick=DisApprove(@Model.trial.TrialSite.ID)>退回</button>
            <button type="button" class="btn btn-default" onclick=DelConfirm(@Model.trial.TrialSite.ID)>删除</button>
        </div>
    }
    else if (Model.trial.Status == 3)
    {
        <div style="text-align:center;margin:20px;margin-bottom:200px" id="divRollback">
            <button type="button" class="btn btn-default" onclick=RollBack(@Model.trial.TrialSite.ID)>撤回批准</button>
            <button type="button" class="btn btn-default" onclick=DelConfirm(@Model.trial.TrialSite.ID)>删除</button>
        </div>
    }

</div>
<style>
    .leftContent {
        float: left;
        margin-top: 5px;
        margin-left: 10px;
    }

    .rightContent {
        float: right;
        text-align: right;
        margin-top: 5px;
    }
</style>
@if (Model.isExistTrialGuide == true)
{
    <script>
        DynamicDisplayFromLeft('@Model.trialGuide.Purpose', "示范目的", "PurposeTable")
        DynamicDisplayFromLeft('@Model.trialGuide.Agentia', "供试药剂", "PurposeTable")
        DynamicDisplayFromLeft('@Model.trialGuide.Object', "防除对象", "PurposeTable")
        DynamicDisplayFromLeft('@Model.trialGuide.CropCategory', "季节", "PurposeTable")
        DynamicDisplayFromLeft('@Model.trialGuide.SubCropCategory', "作物品种", "PurposeTable")
        DynamicDisplayWithTextBoxFromLeft('@Model.trialGuide.Others', "示范方案", "PurposeTable", 'Others')
    </script>
}

@for (int i = 0; i < Model.BasicInfoList.Count() / 2; i++)
{
    <script>
        DynamicDisplayForBasic('@Model.BasicInfoList[i].value', '@Model.BasicInfoList[i].ChineseDesc', "BasicTable")
    </script>
}

@for (int i = Model.BasicInfoList.Count() / 2; i < Model.BasicInfoList.Count(); i++)
{
    <script>
        DynamicDisplayForBasic('@Model.BasicInfoList[i].value', '@Model.BasicInfoList[i].ChineseDesc', "BasicRightTable")
    </script>
}
<script>
    $(".AdminInfo").attr("disabled", true);

    DynamicDisplay('@Model.trial.ProductCategory.Name', "产品类别", "TrialInfoLeftTable")
    DynamicDisplay('@Model.trial.Product', "产品", "TrialInfoLeftTable")
    DynamicDisplay('@Model.trial.Crop', "农作物", "TrialInfoLeftTable")
    DynamicDisplay('@Model.trial.Promoter', "实验员", "TrialInfoLeftTable")
    DynamicDisplay('@Model.trial.Province', "省份", "TrialInfoRightTable")
    DynamicDisplay('@Model.CreateDateTime', "创建时间", "TrialInfoRightTable")
    DynamicDisplay('@Model.SubmitDateTime', "提交时间", "TrialInfoRightTable")
    DynamicDisplay('@Model.FinishDateTime', "完成时间", "TrialInfoRightTable")

    DynamicFinalReportDisplayFromLeft('@Model.LastObserveDateTime', "最后一次调查时间", "FinalTable", 'LastObserveDate')
    DynamicFinalReportDisplayFromLeft('@Model.trial.TrialSite.IsAcceptable', "对此药农户是否接受", "FinalTable", 'IsAcceptable')

    DynamicFinalReportDisplayFromLeft('@Model.trial.TrialSite.EffectResult', "最后一次调查目测药效", "FinalTable", 'EffectResult')
    DynamicFinalReportDisplayFromLeftWithTextBox('@Model.trial.TrialSite.EffectDescription', "具体药效描述（动态过程）", "FinalTable", 'EffectDescription')
    DynamicFinalReportDisplayFromLeftWithTextBox('@Model.trial.TrialSite.CropDescription', "其它说明", "FinalTable", 'CropDescription')
    DynamicFinalReportDisplayFromLeftWithTextBox('@Model.trial.TrialSite.YieldEffect', "对产量影响%(减产用负值表示）", "FinalTable", 'YieldEffect')
    DynamicFinalReportDisplayFromLeftWithTextBox('@Model.trial.TrialSite.Comments', "备注", "FinalTable", 'Comments')

    //获取项目列表
    ProcessAjaxRequest(fixUrl('api/Trial/GetProjectCategories'), "get", "", function (data) {
        $("#projectCategory").html('');
        $("#projectCategory").append("<option value='" + 0 + "'>" + '请选择' + "</option>");
        for (var i = 0; i < data.length; i++) {
            $("#projectCategory").append("<option value='" + data[i].ID + "'>" + data[i].Name + "</option>");
        }
        $("#projectCategory").val(@Model.ProjectCategoryID);
    })
    //获取Admin信息
    ProcessAjaxRequest(fixUrl("api/Common/GetAdmins"), "get", "", function (data) {
        $("#ttmItem").html('');
        $("#ttmItem").append("<option value='" + 0 + "'>" + '请选择' + "</option>");
        for (var i = 0; i < data.length; i++) {
            $("#ttmItem").append("<option value='" + data[i].ID + "'>" + data[i].Name + "</option>");
        }
        $("#ttmItem").val(@Model.TTMID);
    })

    function Approve(id) {
        $.ajax({
            url: fixUrl('api/Trial/ApproveTrial'),
            type: "post",
            data: { ID: id },
            success: function (data) {
                AlertCompleteBox("操作成功");
                $("#divOperate").css("display", "none");
            }
        });
    }

    function DisApprove(id) {
        $.ajax({
            url: fixUrl("api/Trial/DisApproveTrial"),
            type: "post",
            data: { ID: id },
            success: function (data) {
                AlertCompleteBox("操作成功");
                $("#divOperate").css("display", "none");
            }
        });
    }

    function RollBack(id) {
        $.ajax({
            url: fixUrl("api/Trial/RollBackTrial"),
            type: "post",
            data: { ID: id },
            success: function (data) {
                AlertCompleteBox("操作成功");
                $("#divRollback").css("display", "none");
            }
        });
    }

    function Reminder(id) {
        $.ajax({
            url: fixUrl("api/Trial/ReminderTask"),
            type: "post",
            data: { ID: id },
            success: function (data) {
                AlertCompleteBox("发送提醒成功");
            }
        });
    }
    $("#btnEdit").click(function () {
        $(".AdminInfo").removeProp("disabled");
        $("#btnEdit").css("display", "none");
        $("#btnSave").css("display", "inline-block");
    })
    $("#btnSave").click(function () {
        if ($("#ttmItem option:selected").val() <= 0 || $("#projectCategory option:selected").val() <= 0) {
            AlertErrorBox("信息填写不完整");
        } else {
            ProcessAjaxRequest(fixUrl("api/Trial/UpdateAdminInfo"), "post", {
                TrialID: '@Model.trial.TrialID', TTMID: $("#ttmItem option:selected").val(),
                FSM: $("#fsmItem").val(), CA: $("#caItem").val(), ProjectCategoryID: $("#projectCategory option:selected").val()
            }, function (data) {
                AlertCompleteBox("信息保存成功");
                $("#btnSave").css("display", "none");
                $(".AdminInfo").attr("disabled", true);
            })
        }
    })

    function Changesize() {
        if ($(".mainCont").css("top") == "0px") {
            $(".mainCont").css("top", "100px");
        } else {
            $(".mainCont").css("top", "0px");
        }
    }

    function DelConfirm(id) {
        AlertMsgBoxWithFunction('删除确认', '确认删除该试验点信息吗？', '确认', '取消', function () { DelTrial(id) }, function () { layer.close() })
    }

    function DelTrial(id) {
        $.ajax({
            url: fixUrl("api/Trial/DelTrialSite"),
            type: "post",
            data: { ID: id },
            success: function (data) {//reload grid
                AlertCompleteBox("操作成功");
                window.location.reload();
            },
            error: function (err) {
                if (err.status == "401") {
                    AlertErrorBox("当前用户未登录，或登录已超时");
                } else {
                    AlertErrorBox("处理请求失败");
                }
            }
        });
    }

</script>